import request from '@/utils/request/index'
import type {
  TradeMarkResponseData,
  TradeMark,
  successResponseData
} from './type'

enum API {
  TRADEMARK_URL = '/admin/product/baseTrademark/',
  ADDTRADEMARK_URL = '/admin/product/baseTrademark/save',
  UPDATETRADEMARK_URL = '/admin/product/baseTrademark/update',
  DELETETRADEMARK_URL = '/admin/product/baseTrademark/remove/'
}

export const reqHasTrademark = (pageNo: number, limit: number) =>
  request.get<TradeMarkResponseData>(`${API.TRADEMARK_URL}${pageNo}/${limit}`)

export const reqAddOrUpdateTrademark = (data: TradeMark) => {
  if (data.id) {
    return request.put<successResponseData>(API.UPDATETRADEMARK_URL, data)
  } else {
    return request.post<successResponseData>(API.ADDTRADEMARK_URL, data)
  }
}

export const reqDeleteTrademark = (id: number) =>
  request.get<successResponseData>(`${API.TRADEMARK_URL}${id}`)
